import { FormFieldConfig } from "@/types/form"
import { getFormFields } from "@/utils/formUtils"

// 表格列配置
export const tableColumns = [
  {
    title:'ID',
    dataIndex: 'id',
  },
  {
    title: '駐診形式',
    dataIndex: 'shiftType',
  },
  {
    title: '起始日期',
    dataIndex: 'startDate',
  },
  {
    title: '結束日期',
    dataIndex: 'endDate',
    customRender: ({value}) => {
      return value || '未知'
    },
  },
  {
    title: '狀態',
    dataIndex: 'status',
  },
  {
    title: '最後修改人',
    dataIndex: 'updatedBy',
  },
  {
    title: '最後修改時間',
    dataIndex: 'updatedAt',
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
  },

]


 const FormField: Record<string, FormFieldConfig> = {
  shiftType: {
    label: '駐診形式',
    type: 'radio',
    rules: [{ required: true, message: '請選擇駐診形式' }],
    options: [
      { key: 1, label: '全日' },
      { key: 2, label: '半日' },
    ],
    defaultValue:1
  },
  startDate: {
    label: '開始日期',
    type: 'date',
    placeholder: '請選擇開始日期',
    rules: [{ required: true, message: '請選擇開始日期' }],
  },
  endDate: {
    label: '結束日期',
    type: 'date',
    placeholder: '請選擇結束日期',
    rules: [{ required: true, message: '請選擇結束日期' }],
  },

}


// 創建表單字段
export const getCreteFieldConfig = (fields?: string[]) => {
  fields = fields || ['shiftType','startDate']
  return getFormFields(FormField, fields)
}

export const getEditFieldConfig = (fields?: string[]) => {
  fields = fields || ['endDate']
  return getFormFields(FormField, fields)
}

